package com.jyw.system.domain.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jyw.common.utils.DateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Data
@ApiModel("基础时间返回查询")
@NoArgsConstructor
@AllArgsConstructor
public class BaseTimeDto {

    @ApiModelProperty("开始日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date beginDate;

    @ApiModelProperty("结束日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endDate;

    public BaseTimeDto(Date date) {
        setBeginDate(DateUtils.getDateWithoutTime(date));
        setEndDate(DateUtils.toDateLastTime(date));
    }
}
